package com.ibm.productivity.tools.blogplugin;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;

import com.ibm.productivity.tools.blogplugin.meta.IBlogAccount;

public class ExtensionPointGeter {
	public static final String PLUGIN = "com.ibm.productivity.tools.blogplugin";
	public static final String EXTENSION_POINT = "blog";
	public static IBlogAccount[] account = null;

	public static IBlogAccount[] getExtensionAccount() {
		if (account == null) {
			try {
				IConfigurationElement[] elements = Platform
						.getExtensionRegistry().getExtensionPoint(PLUGIN,
								EXTENSION_POINT).getConfigurationElements();
				account = new IBlogAccount[elements.length];
				for (int i = 0; i < elements.length; ++i) {
					String id = elements[i].getAttribute("id");
					System.out.println("Find extension: "+id);
					account[i] = (IBlogAccount) elements[i]
							.createExecutableExtension("class");
					

				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return account;
	}
}
